package com.yanqu.road.server.cmd.banquet.goodbanquet;

import com.yanqu.road.entity.banquet.baifubanquet.GoodBanquet;
import com.yanqu.road.pb.banquet.CrossBanquetProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.manager.banquet.baifubanquet.CrossGoodBanquetMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;


@Cmd(code = Protocol.C2_GOOD_BANQUET_RECEIVE_SETTLEMENT_SUCCESS, desc = "百福宴回调给跨服 区服接收到结算信息")
public class CrossGoodBanquetReceiveSettlementSuccessCmd extends CrossCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        CrossBanquetProto.GoodBanquetReceiveSettlementToCrossReqMsg reqMsg = CrossBanquetProto.GoodBanquetReceiveSettlementToCrossReqMsg.parseFrom(packet.getBytes());
        for (long banquetId : reqMsg.getIdList()){
            GoodBanquet goodBanquet = CrossGoodBanquetMgr.getUserFinishBanquetMap().remove(banquetId);
            if(goodBanquet == null){
                CrossGoodBanquetMgr.logger.error("收到的百福宴会id，结算集合中不存在。banquetId:{},activityId:{}",banquetId,reqMsg.getActivityId());
                continue;
            }
            goodBanquet.getBanquetData().setIsSettlement(true);
        }
    }

    @Override
    public void sendData() {

    }
}
